package tripx.db;

import java.util.HashMap;

import com.mysql.jdbc.PreparedStatement;

/**
 * The property for the <code><b>DbService</code></b>. It maintains the data
 * which is common for all instances of <code><b>DbService</b></code>
 * 
 * @author zhb
 * 
 */
public class DbServiceProperty {

	private static DbServiceProperty property;

	HashMap<String, PreparedStatement> preparedStatements;

	private DbServiceProperty() {
		preparedStatements = new HashMap<String, PreparedStatement>();
	}

	public static DbServiceProperty getInstance() {
		if (property == null) {
			property = new DbServiceProperty();
		}
		return property;
	}

	/**
	 * add a new <code><b>PreparedStatement</b></code>
	 * 
	 * @param key
	 * @param statement
	 */
	public void addPreparedStatement(String key, PreparedStatement statement) {
		preparedStatements.put(key, statement);
	}

	/**
	 * get the <code<b>PreparedStatement</b></code> by the key.
	 * 
	 * @param key
	 * @return
	 */
	public PreparedStatement getPreparedStatement(String key) {
		return preparedStatements.get(key);
	}

	/**
	 * check whether the key is exist.
	 * 
	 * @param key
	 * @return
	 */
	public boolean containsKey(String key) {
		return preparedStatements.containsKey(key);
	}
}
